﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Pex.Framework;


namespace Benchmarks.McMinnThesisBen
{
    [TestClass, PexClass(typeof(ArrayDiff))]    
    public class ArrayDiff
    {
        static int SIZE = 10;
        int[] last;
        bool init;
        
        public ArrayDiff()
        {
            last = new int[SIZE];
            init = true;
        }

        public bool Diff(int[] incoming)
        {
            PexAssume.IsTrue(incoming != null);
            PexAssume.IsTrue(incoming.Length == SIZE);

            bool diff = false;
            int i;
            if (!init)
            {
                for (i = 0; i < SIZE; i++)
                {
                    if (incoming[i] != last[i])
                    {
                        diff = true;
                    }
                }
            }
            if (diff || init)
            {
                for (i = 0; i < SIZE; i++)
                {
                    last[i] = incoming[i];
                }
            }
            if (init)
            {
                init = false;
            }
            return diff;
        }

        //README of running these test methods with Pex
        //For each METHODNAME, run with C:\pex\bin\Debug>Pex Benchmarks.dll /mf:METHODNAME
        // adding /fte outputs all generated tests


        //in run 9, cover all
        //but not using fitness internally, need to debug why
        //[PexMethod(MaxRuns = 10, MaxConditions = int.MaxValue, MaxRunsWithoutNewTests = int.MaxValue)]        
        //public void TestArrayDiffFitness(int[][] incomings) 
        //{
        //    TestArrayDiff(incomings);
        //}

        ////in run 7, cover all
        //[PexMethod(MaxRuns = 10, MaxConditions = int.MaxValue, MaxRunsWithoutNewTests = int.MaxValue)]        
        //public void TestArrayDiffDefault(int[][] incomings)
        //{
        //    TestArrayDiff(incomings);
        //}
    
        //private void TestArrayDiff(int[][] incomings)
        //{
        //    PexAssume.IsTrue(incomings != null);

        //    ArrayDiff c = new ArrayDiff();
        //    for (int i = 0; i <= (incomings.Length - 1); i++)
        //        c.Diff(incomings[i]);
        //}
    }
}
